/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.nb.jobs.properties;

import coalescent.phylogeny.PhylogenyAlgo;
import commons.nb.jobs.properties.PropertyImpl;

import java.util.Properties;

/**
 * @author Susanta Tewari
 * @version 1.0.0
 * @history Created on Nov 23, 2011
 * @since 1.0.0
 */
public class CoalescentPropertyImpls {

    /**
     * Class description
     *
     *
     * @version        Enter version here..., 12/10/09
     * @author         Susanta Tewari
     */
    public static class PhylogenyAlgorithmPropertyImpl extends PropertyImpl {

        /** Field description */
        private PhylogenyAlgo value;

        /**
         * Method description
         *
         *
         * @return
         */
        public PhylogenyAlgo getValue() {
            return value;
        }

        /**
         * Method description
         *
         *
         * @param value
         */
        public void setValue(final PhylogenyAlgo value) {
            this.value = value;
        }

        /**
         * Method description
         *
         *
         * @return
         */
        @Override
        public Class getPropertyType() {
            return PhylogenyAlgo.class;
        }

        /**
         * Method description
         *
         *
         * @return
         */
        @Override
        public String getKeyValue() {
            return value.name();
        }

        /**
         * Method description
         *
         *
         * @param p
         */
        @Override
        public void setPropertyImpl(final Properties p) {

            final String key = getKey();

            if (!p.containsKey(key)) {
                return;
            }

            final PhylogenyAlgo val = PhylogenyAlgo.valueOf(p.getProperty(key));

            if (val != null) {
                setValue(val);
            }
        }
    }
}
